package fiuba.td.fabrica.controller;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Observable;

import fiuba.td.fabrica.constants.GlobalConstants;
import fiuba.td.fabrica.model.entities.Terreno;
import fiuba.td.fabrica.model.exceptions.SinDineroException;
import fiuba.td.fabrica.model.partida.Partida;
import fiuba.td.fabrica.view.utils.AlertUtils;

public class ControllerComprarTerreno extends Observable implements MouseListener{
	Terreno terrenoSeleccionado;
	public ControllerComprarTerreno(){
		super();		
	}
	
	public void mouseClicked(MouseEvent arg0) {
		this.terrenoSeleccionado = ControllerSelection.getInstance().getTerrenoSeleccionado();
		String notificationMsg = GlobalConstants.BOTON_TERRENOS_COMPRAR;
		
		try {
			Partida.getInstance().comprarTerreno(this.terrenoSeleccionado, "Fabrica Cool");
		} catch (SinDineroException e) {
			AlertUtils.show("No tiene dinero para comprar el terreno");
			notificationMsg = GlobalConstants.BOTON_TERRENOS_COMPRAR_SIN_DINERO;
		}
	
		setChanged();
		notifyObservers(notificationMsg);
	}

	
	public void mouseEntered(MouseEvent arg0) {
	}

	
	public void mouseExited(MouseEvent arg0) {
	}

	
	public void mousePressed(MouseEvent arg0) {
	}

	
	public void mouseReleased(MouseEvent arg0) {
	}

}
